package ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.fy.fyzf.R;
import com.fy.fyzf.base.BaseActivity;
import com.fy.fyzf.bean.ExChangeRecordBean;
import com.fy.fyzf.bean.ExchangeBean;
import com.fy.fyzf.bean.ExchangeDetailBean;
import com.fy.fyzf.bean.IntegralRecordBean;
import com.fy.fyzf.bean.IntegralStoreBean;
import com.fy.fyzf.bean.RulesBean;
import com.fy.fyzf.glideUtils.GlideUtils;
import com.fy.fyzf.presenter.IntergralPresenter;
import com.fy.fyzf.view.IntergralCallBack;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ConfirmOrderActivity extends BaseActivity<IntergralPresenter> implements IntergralCallBack {

    @BindView(R.id.iv_logo)
    ImageView ivLogo;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_sorce)
    TextView tvSorce;
    @BindView(R.id.tv_sorce1)
    TextView tvSorce1;
    @BindView(R.id.tv_sure)
    TextView tvSure;
    private IntegralStoreBean.ListBean data;

    @Override
    protected IntergralPresenter createPresenter() {
        return new IntergralPresenter(this);
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_confirm_order;
    }

    @Override
    public void initView() {
        super.initView();
        setTitleName("订单确认");
    }


    @Override
    public void initData() {
        super.initData();
        data = (IntegralStoreBean.ListBean) getIntent().getSerializableExtra("data");
        GlideUtils.loadImage(data.getMallUrl(),ivLogo);
        tvName.setText(data.getMallTitle());
        tvSorce.setText(data.getMallIntegral()+"");
        tvSorce1.setText(data.getMallIntegral()+"积分");

    }

    @Override
    public void getIntegralListSuccess(IntegralStoreBean integralStoreBean) {

    }

    @Override
    public void exchangeSuccess(ExchangeBean exchangeBean) {
        //兑换结果
        Intent intent = new Intent(this,ExchangeResultActivity.class);
        intent.putExtra("status", exchangeBean.isSuccess());
        intent.putExtra("id", exchangeBean.getExchangeId());
        startActivity(intent);
        EventBus.getDefault().post("exchangeSuccess");
        finish();
    }

    @Override
    public void getExchangeDetailSuccess(ExchangeDetailBean exchangeDetailBean) {

    }

    @Override
    public void getExchangeRecordSuccess(ExChangeRecordBean exChangeRecordBean) {

    }

    @Override
    public void getIntegralRecordListSuccess(IntegralRecordBean integralRecordBean) {

    }

    @Override
    public void getRulesSuccess(List<RulesBean> list) {

    }


    @OnClick({R.id.tv_sorce1, R.id.tv_sure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_sorce1:
                break;
            case R.id.tv_sure:
                ExchangeBean exchangeBean = new ExchangeBean();
                exchangeBean.setMallId(data.getMallId());
                mPresenter.exChange(exchangeBean);
                break;
        }
    }
}